package edu.hz.dao;

import edu.hz.model.entity.UserDonationEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserDonationMapper {

    @Insert("insert into user_donations(user_id, donation_id, donation_type, money, detail, donation_time) VALUES " +
    "(#{userId}, #{donationId}, #{donationType}, #{money}, #{detail}, #{donationTime})")
    int insertUserDonation(UserDonationEntity userDonationEntity);

    @Select("select * from user_donations order by id desc limit #{count}")
    List<UserDonationEntity> getLastUserDonations(@Param("count") Integer count);

    @Select("select * from user_donations where donation_id = #{donationId}")
    List<UserDonationEntity> selectByDonationId(@Param("donationId") Integer donationId);

}
